import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:untitled/pages/info_page.dart';
import 'package:untitled/pages/settings_page.dart';
import 'package:untitled/video/CacheVideoExample.dart';
import 'package:untitled/video/VideoPlayerChewiePage.dart';
import 'package:untitled/video/VideoPlayerScreen.dart';

import 'animate/main-container.dart';
import 'image/ImageSelectExample.dart';
import 'other/main-Segmented.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      // initialRoute: '/settings',
      //配置路由
      routes: {
        // '/': (context) => SettingsPage(),
        '/settings': (context) => SettingsPage(),
        '/info': (context) => InfoPage(),
      },
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      // home: const MyHomePage(title: 'Flutter Demo Home Page'),
      // home: TestHomePage1(),
      // home: TestHomePage2(),
      home: HomeIndexPage(),
    );
  }
}

class HomeIndexPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('首页')),
      body: ListView(
        children: [
          ListTile(
            title: Text('VideoPlayer 视频播放'),
            onTap: () {
              Get.to(() => VideoPlayerScreen());
            },
          ),
          ListTile(
            title: Text('VideoPlayer + Chewie 视频播放'),
            onTap: () {
              Get.to(() => VideoPlayerChewiePage());
            },
          ),
          ListTile(
            title: Text('VideoPlayer +  视频缓存'),
            onTap: () {
              Get.to(() => CacheVideoExample());
            },
          ),
          ListTile(
            title: Text('相机与相册 '),
            onTap: () {
              Get.to(() => ImageSelectExample());
            },
          ),
          ListTile(
            title: Text('iOS 风格分段指示器 '),
            onTap: () {
              Get.to(() => SegmentedHomePage());
            },
          ),
          ListTile(
            title: Text('AnimateContainer动画 '),
            onTap: () {
              Get.to(() => AnimateContainerPage());
            },
          ),
        ],
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            SizedBox(
              width: 200,
              height: 200,
              child: Text(
                'Hello FlutterHello FlutterHello FlutterHello FlutterHello FlutterHello FlutterHello FlutterHello Flutter ',
                textAlign: TextAlign.center, //对齐方式
                maxLines: 3, //最大行数
                overflow: TextOverflow.fade, //文本溢出时处理方式
                softWrap: true, //是否自动换行

                style: TextStyle(
                  fontWeight: FontWeight.bold, //文字粗细
                  fontSize: 23, //文字大小
                  color: Colors.red, //文字颜色
                  letterSpacing: 4, //字符之间的间距
                  height: 2, //行高 倍数
                  backgroundColor: Colors.white, //文字背景颜色
                  decoration: TextDecoration.underline, //下划线的位置
                  decorationColor: Colors.green, //下划线的颜色
                  decorationStyle: TextDecorationStyle.dotted, //下划线的样式
                  shadows: [
                    //阴影
                    Shadow(
                      color: Colors.black,
                      offset: Offset(2, 2),
                      blurRadius: 4,
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
